package com.lanou3g.ptp.utils;

import org.springframework.util.MimeTypeUtils;

import java.util.UUID;

public class FileNameUtils {
    public static String generateFileName(String mimeType) {
        String fileName = UUID.randomUUID().toString().replaceAll("-", "");
        if (MimeTypeUtils.IMAGE_JPEG_VALUE.equalsIgnoreCase(mimeType)) {
            return fileName + ".jpg";
        }
        if (MimeTypeUtils.IMAGE_PNG_VALUE.equalsIgnoreCase(mimeType)) {
            return fileName + ".png";
        }
        if (MimeTypeUtils.IMAGE_GIF_VALUE.equalsIgnoreCase(mimeType)) {
            return fileName + ".gif";
        }
        return null;
    }
}
